﻿using BLL;
using MODEL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Loginter.系统维护
{
    public partial class SyslogSelect : System.Web.UI.Page
    {
        SyslogBLL bll = new SyslogBLL();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Type();
                BindSyslogList();
            }
        }

        private void Type()
        {
            DataTable table = bll.GetLogDicInfo();
            drop_type.DataSource = table;
            drop_type.DataTextField = "TypeName";
            drop_type.DataValueField = "TypeName";
            drop_type.DataBind();
            drop_type.Items.Insert(0, new ListItem("--不限--", "0"));
        }
        private void BindSyslogList()
        {
            string type = drop_type.SelectedValue;
            string account = txt_account.Text.Trim();
            DateTime? date_in = null;
            if (!string.IsNullOrWhiteSpace(dateinput.Value.Trim()))
            {
                date_in = Convert.ToDateTime(dateinput.Value);
            }
            DateTime? data_end = null;
            if (!string.IsNullOrWhiteSpace(dateinput.Value.Trim()))
            {
                data_end = Convert.ToDateTime(dateinput.Value);
            }
            int diao = radio_isok.SelectedIndex;
            string cun = txt_cunchu.Text.Trim();
            SyslogMODEL syolg = new SyslogMODEL()
            {
                TypeName=type,
                Account=account,
                datein=date_in,
                dateend=date_in,
                IsException = diao,
                ProcName=cun
            };
            List<SyslogQueryModel> list = bll.GetSyslogInfo(syolg);
            repter_Syslog.DataSource = list;
            repter_Syslog.DataBind();

        }

        protected void btn_jiansuo_Click(object sender, EventArgs e)
        {
            BindSyslogList();
        }

        protected void btn_chongzhi_Click(object sender, EventArgs e)
        {
            drop_type = null;
            txt_account = null;
            txt_cunchu = null;
            dateinput = null;
            dateinput = null;
        }

        protected void btn_add_Click(object sender, EventArgs e)
        {
            Response.Redirect("AddUserInfo.aspx");
        }
    }
}